/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.network.miscellaneous.mirror;

import java.awt.Color;

import javax.swing.ImageIcon;

import twaver.Element;
import twaver.Follower;
import twaver.Node;
import twaver.SelectableFilter;
import twaver.TWaverConst;
import twaver.TWaverUtil;
import twaver.network.TNetwork;
import twaver.network.background.ColorBackground;
import demo.DemoPane;

public class MirrorDemo extends DemoPane {
	
    public MirrorDemo() {
        TNetwork network = new TNetwork();
        network.setNetworkBackground(new ColorBackground(Color.black));

        Node node = new Node();
        node.setImage("/demo/network/miscellaneous/mirror/equipment.png");
        node.putBorderColor(Color.green);
        node.putBorderInsets(5);
        node.putBorderAntialias(true);
        node.putBorderStroke(TWaverConst.STROKE_SOLID_4);
        node.setLocation(100, 100);
        network.getDataBox().addElement(node);

        ImageIcon shadowImage = TWaverUtil.createShadowImage(node.getImage().getImage(), 3);
        TWaverUtil.registerImageIcon("shadow", shadowImage);

        Follower shadowNode = new Follower();
        shadowNode.setImage("shadow");
        shadowNode.putBorderVisible(false);
        int shadowGap = 10;
        shadowNode.setLocation(node.getLocation().x, node.getLocation().y + node.getHeight() + shadowGap);
        network.getDataBox().addElement(shadowNode);
        shadowNode.setHost(node);

        network.addSelectableFilter(new SelectableFilter() {
            public boolean isSelectable(Element element) {
                return! (element instanceof Follower);
            }
        });
        
        this.add(network);
    }
}